<template>
    <view class="container" v-if="order.uuid">
        <view class="user-c">
            <view class="top">
                <image class="headimg" mode="widthFix" :src="user.headimg"></image>
                <view class="name">{{ user.name }}</view>
            </view>
            <view class="middle">请你帮他付款</view>
            <view class="bottom"></view>
        </view>
        <view class="products-c">
            <sku-item @__l="__l" class="sku" :info="item" :vueId="'320c2ce3-1-' + index" v-for="(item, index) in skus" :key="index"></sku-item>
        </view>
        <view class="price-wrap padding-h">
            <view class="list-item">
                <view class="body">商品总价</view>
                <view class="arrow-right">
                    <price-display @__l="__l" :info="order" prefix="product_" vueId="320c2ce3-2"></price-display>
                </view>
            </view>
            <view class="list-item" v-if="order.cover_type">
                <view class="body">兑换类型</view>
                <view class="arrow-right">
                    <text class="meta" v-if="order.cover_type === 'chip'">碎片兑换</text>
                    <block v-else>
                        <text class="meta" v-if="order.cover_type === 'score'">{{ scoreAlias + '兑换' }}</text>
                    </block>
                </view>
            </view>
            <view class="list-item" v-if="order.cover_discount">
                <view class="body">兑换抵扣</view>
                <view class="arrow-right">{{ '-¥' + $root.f0 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">优惠券</view>
                <view class="arrow-right">{{ '-¥' + $root.f1 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">红包</view>
                <view class="arrow-right">{{ '-¥' + $root.f2 + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">运费</view>
                <view class="arrow-right" v-if="order.carriage_type === 2">到付</view>
                <view class="arrow-right" v-else>{{ '+¥' + $root.f3 + '' }}</view>
            </view>
            <view class="total-price border-top">
                <view style="padding-left: 14rpx">
                    <text class="key">实付:</text>
                    <view class="price-c">
                        <price-display @__l="__l" :info="order" prefix="pay_" vueId="320c2ce3-3"></price-display>
                    </view>
                </view>
            </view>
        </view>
        <view class="meta-c padding-h">
            <view class="list-item">
                <view class="body">订单编号</view>
                <view class="arrow-right">
                    {{ '' + order.number + '' }}
                    <text @tap="__e" :data-event-opts="[['tap', [['setCopyText', ['$0'], ['order.number']]]]]" style="color: #1890ff; margin-left: 10rpx">复制</text>
                </view>
            </view>
            <view class="list-item" v-if="order.created_at">
                <view class="body">下单时间</view>
                <view class="arrow-right">{{ '' + order.created_at + '' }}</view>
            </view>
            <view class="list-item" v-if="order.paid_at">
                <view class="body">支付时间</view>
                <view class="arrow-right">{{ '' + order.paid_at + '' }}</view>
            </view>
            <view class="list-item">
                <view class="body">代付状态</view>
                <view class="arrow-right status-text">
                    <block v-if="info.status === 0">待支付</block>
                    <block v-else>
                        <text style="color: #2ba246" v-if="info.status === 2">已完成</text>
                        <block v-else>
                            <text style="color: red" v-if="info.status === 3">已失效</text>
                        </block>
                    </block>
                </view>
            </view>
        </view>
        <view style="height: 150rpx"></view>
        <view class="footer-actions safe-area-bottom">
            <block v-if="info.status === 0">
                <button class="btn btn-full bg-orange" openType="share" v-if="user.id === userInfo.id">
                    <text>转发给好友支付</text>
                </button>
                <view @tap="__e" class="btn btn-full bg-orange" :data-event-opts="[['tap', [['paySubmit', ['$event']]]]]" v-else>
                    <text>帮他付款</text>
                </view>
            </block>
            <block v-else>
                <block v-if="info.status === 2">
                    <view @tap="__e" class="btn btn-full bg-green" :data-event-opts="[['tap', [['checkOrder', ['$event']]]]]" v-if="user.id === userInfo.id">
                        <text>已完成 查看订单</text>
                    </view>
                    <view class="btn btn-full bg-green" v-else>
                        <text>此代付已完成</text>
                    </view>
                </block>
                <block v-else>
                    <view class="btn btn-full bg-gray" v-if="info.status === 3">
                        <text>此代付已过期</text>
                    </view>
                </block>
            </block>
        </view>
        <i-action-sheet
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @change="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            @visibleChange="
                __e($event, {
                    eventOpts: [
                        ['^visibleChange', [['visibleChange']]],
                        ['^change', [['cancelOrder']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^visibleChange', [['visibleChange']]],
                ['^change', [['cancelOrder']]]
            ]"
            :list="reasons"
            title="选择理由"
            :visible="visible"
            vueId="320c2ce3-4"
        ></i-action-sheet>
        <return-sale-popup
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            @cancel="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            @refresh="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['getOrderInfo']]]
                    ]
                })
            "
            :data-event-opts="[
                ['^cancel', [['e0']]],
                ['^refresh', [['getOrderInfo']]]
            ]"
            :uuid="uuid"
            vueId="320c2ce3-5"
            v-if="isShowReturnSalePopup"
        ></return-sale-popup>
    </view>
</template>

<script>
import skuItem from '@/components/SkuItem/SkuItem';
import priceDisplay from '@/components/PriceDisplay/PriceDisplay';
import returnSalePopup from '@/components/ReturnSalePopup/ReturnSalePopup';
import iActionSheet from '@/components/ActionSheet/index';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['pages/agentPayRecord/detail'],
    {
        '2f20': function (e, t, n) {
            'use strict';

            (function (e) {
                var r = n('4ea4');
                Object.defineProperty(t, '__esModule', {
                    value: true
                });
                t.default = void 0;
                var i = r(n('9523'));
                var o = r(n('452d'));
                var u = r(n('82c0'));
                var c = n('26cb');
                function a(e, t) {
                    var n = Object.keys(e);
                    if (Object.getOwnPropertySymbols) {
                        var r = Object.getOwnPropertySymbols(e);
                        if (t) {
                            r = r.filter(function (t) {
                                return Object.getOwnPropertyDescriptor(e, t).enumerable;
                            });
                        }
                        n.push.apply(n, r);
                    }
                    return n;
                }
                function s(e) {
                    for (var t = 1; t < arguments.length; t++) {
                        if (null != arguments[t]) {
                            var n = arguments[t];
                        } else {
                            var n = {};
                        }
                        if (t % 2) {
                            a(Object(n), true).forEach(function (t) {
                                (0, i.default)(e, t, n[t]);
                            });
                        } else {
                            Object.getOwnPropertyDescriptors
                                ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n))
                                : a(Object(n)).forEach(function (t) {
                                      Object.defineProperty(e, t, Object.getOwnPropertyDescriptor(n, t));
                                  });
                        }
                    }
                    return e;
                }
                var d = {
                    mixins: [o.default],
                    components: {
                        IActionSheet: function () {
                            n.e('components/ActionSheet/index')
                                .then(
                                    function () {
                                        return resolve(n('fbfb'));
                                    }.bind(null, n)
                                )
                                .catch(n.oe);
                        }
                    },
                    data: function () {
                        return {
                            visible: false,
                            info: {},
                            order: {},
                            skus: [],
                            user: {},
                            uuid: ''
                        };
                    },
                    computed: s(
                        s({}, (0, c.mapGetters)(['userInfo'])),
                        {},
                        {
                            share: function () {
                                return {
                                    title: this.user.name + '请你代付一个订单'
                                };
                            }
                        }
                    ),
                    filters: {
                        hidePhoneDetail: function (e) {
                            return e ? e.substring(0, 3) + '****' + e.substring(7, 11) : '';
                        }
                    },
                    onLoad: function (e) {
                        var that = this;
                        this.uuid = e.uuid;
                        this.$api.emit('order.cancel_reason.list').then(function (e) {
                            that.reasons = e.data.list;
                        });
                    },
                    onShow: function () {
                        this.initData();
                    },
                    methods: {
                        checkOrder: function () {
                            e.navigateTo({
                                url: '/pages/orderDetail/index?uuid=' + this.order.uuid
                            });
                        },
                        paySubmit: function () {
                            var that = this;
                            e.showLoading({
                                title: '提交中'
                            });
                            this.$http('/agent-pay-records/'.concat(this.uuid, '/pay'), 'POST').then(function (n) {
                                e.hideLoading();
                                u.default.pay({
                                    pay_config: n.data.pay_config,
                                    success: function () {
                                        that.initData();
                                    },
                                    fail: function () {
                                        e.showToast({
                                            title: '支付失败',
                                            icon: 'none'
                                        });
                                    }
                                });
                            });
                        },
                        setCopyText: function (t) {
                            e.setClipboardData({
                                data: t,
                                success: function (t) {
                                    e.showToast({
                                        title: '复制成功'
                                    });
                                }
                            });
                        },
                        initData: function () {
                            var that = this;
                            this.uuid;
                            e.showLoading({
                                title: '加载中',
                                mask: true
                            });
                            this.$http('/agent-pay-records/'.concat(this.uuid)).then(function (n) {
                                e.hideLoading();
                                that.order = n.data.info.order;
                                that.info = n.data.info;
                                that.skus = that.order.skus;
                                that.user = n.data.info.user;
                            });
                        }
                    }
                };
                t.default = d;
            }.call(this, n('543d').default));
        },
        '30e0': function (e, t, n) {
            'use strict';

            var r = n('6058');
            n.n(r).a;
        },
        '45de': function (e, t, n) {
            'use strict';

            (function (e, t) {
                var r = n('4ea4');
                n('18ba');
                r(n('66fd'));
                var i = r(n('62eb'));
                e.__webpack_require_UNI_MP_PLUGIN__ = n;
                t(i.default);
            }.call(this, n('bc2e').default, n('543d').createPage));
        },
        '5f55': function (e, t, n) {
            'use strict';

            n.r(t);
            var r = n('2f20');
            var i = n.n(r);
            for (var o in r) {
                if (['default'].indexOf(o) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return r[e];
                        });
                    })(o);
                }
            }
            t.default = i.a;
        },
        6058: function (e, t, n) {},
        '62eb': function (e, t, n) {
            'use strict';

            n.r(t);
            var r = n('d56c');
            var i = n('5f55');
            for (var o in i) {
                if (['default'].indexOf(o) < 0) {
                    (function (e) {
                        n.d(t, e, function () {
                            return i[e];
                        });
                    })(o);
                }
            }
            n('30e0');
            var u = n('f0c5');
            var c = Object(u.a)(i.default, r.b, r.c, false, null, null, null, false, r.a, void 0);
            t.default = c.exports;
        },
        d56c: function (e, t, n) {
            'use strict';

            n.d(t, 'b', function () {
                return i;
            });
            n.d(t, 'c', function () {
                return o;
            });
            n.d(t, 'a', function () {
                return r;
            });
            var r = {
                SkuItem: function () {
                    return Promise.all([n.e('common/vendor'), n.e('components/SkuItem/SkuItem')]).then(n.bind(null, '3c3e'));
                },
                PriceDisplay: function () {
                    return n.e('components/PriceDisplay/PriceDisplay').then(n.bind(null, '6b05'));
                },
                ReturnSalePopup: function () {
                    return n.e('components/ReturnSalePopup/ReturnSalePopup').then(n.bind(null, 'f4ef'));
                }
            };
            var i = function () {
                var that = this;
                var t = (that.$createElement, that._self._c, that.order.uuid && that.order.cover_discount ? that._f('priceToFixed')(that.order.cover_discount) : null);
                if (that.order.uuid) {
                    var n = that._f('priceToFixed')(that.order.coupon_discount);
                } else {
                    var n = null;
                }
                var r = that.order.uuid ? that._f('priceToFixed')(that.order.redpack_discount) : null;
                var i = that.order.uuid && 2 !== that.order.carriage_type ? that._f('priceToFixed')(that.order.carriage) : null;
                that._isMounted ||
                    (that.e0 = function (t) {
                        that.isShowReturnSalePopup = false;
                    });
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            f0: t,
                            f1: n,
                            f2: r,
                            f3: i
                        }
                    }
                );
            };
            var o = [];
        }
    },
    [['45de', 'common/runtime', 'common/vendor']]
]);
</script>
<style>
@import './detail.css';
</style>
